From 92b9cad184382f3ae471e6bf0a1b45d1e8897499 Mon Sep 17 00:00:00 2001 From: "emellor@leeni.uk.xensource.com" Date: Tue, 21 Mar 2006 11:49:29 +0100 Subject: [PATCH] Break out common parts of vtpm tests into new vtpm_utils library. Signed-off-by: Ewan Mellor --- tools/xm-test/tests/vtpm/01_vtpm-list_pos.py | 9 +-------- tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py | 17 +---------------- tools/xm-test/tests/vtpm/03_vtpm-susp_res.py | 17 +---------------- tools/xm-test/tests/vtpm/Makefile.am | 4 +--- tools/xm-test/tests/vtpm/vtpm_utils.py | 19 +++++++++++++++++++ 5 files changed, 23 insertions(+), 43 deletions(-) create mode 100644 tools/xm-test/tests/vtpm/vtpm_utils.py diff --git a/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py b/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py index 0aa45f1d37..f5c428e1ca 100644 --- a/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py +++ b/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py @@ -8,17 +8,10 @@ from XmTestLib import * +from vtpm_utils import * import commands import os -def vtpm_cleanup(domName): - # Since this is only a temporary domain I clean up the domain from the - # virtual TPM directory - os.system("/etc/xen/scripts/vtpm-delete %s" % domName) - -if ENABLE_HVM_SUPPORT: - SKIP("vtpm-list not supported for HVM domains") - config = {"vtpm":"instance=1,backend=0"} domain = XmTestDomain(extraConfig=config) diff --git a/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py b/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py index 18021380d8..ab948b827d 100644 --- a/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py +++ b/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py @@ -7,26 +7,11 @@ # check list of pcrs from XmTestLib import * +from vtpm_utils import * import commands import os import os.path -def vtpm_cleanup(domName): - # Since this is only a temporary domain I clean up the domain from the - # virtual TPM directory - os.system("/etc/xen/scripts/vtpm-delete %s" % domName) - -if ENABLE_HVM_SUPPORT: - SKIP("vtpm-list not supported for HVM domains") - -if os.path.exists("/dev/tpm0") == False: - SKIP("This machine has no hardware TPM; cannot run this test") - -output = commands.getoutput("ps aux | grep vtpm_manager | grep -v grep") -if output == "": - SKIP("virtual TPM manager must be started to run this test") - -# vtpm manager has been detected config = {"vtpm":"instance=1,backend=0"} domain = XmTestDomain(extraConfig=config) diff --git a/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py b/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py index f4f6191edb..793e4b2afc 100644 --- a/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py +++ b/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py @@ -8,26 +8,11 @@ # check list of pcrs again from XmTestLib import * +from vtpm_utils import * import commands import os import os.path -def vtpm_cleanup(domName): - # Since this is only a temporary domain I clean up the domain from the - # virtual TPM directory - os.system("/etc/xen/scripts/vtpm-delete %s" % domName) - -if ENABLE_HVM_SUPPORT: - SKIP("vtpm-list not supported for HVM domains") - -if os.path.exists("/dev/tpm0") == False: - SKIP("This machine has no hardware TPM; cannot run this test") - -output = commands.getoutput("ps aux | grep vtpm_manager | grep -v grep") -if output == "": - SKIP("virtual TPM manager must be started to run this test") - -# vtpm manager has been detected config = {"vtpm":"instance=1,backend=0"} domain = XmTestDomain(extraConfig=config) diff --git a/tools/xm-test/tests/vtpm/Makefile.am b/tools/xm-test/tests/vtpm/Makefile.am index 5ee4cfb071..3e11292827 100644 --- a/tools/xm-test/tests/vtpm/Makefile.am +++ b/tools/xm-test/tests/vtpm/Makefile.am @@ -1,4 +1,3 @@ - SUBDIRS = TESTS = 01_vtpm-list_pos.test \ @@ -7,8 +6,7 @@ TESTS = 01_vtpm-list_pos.test \ XFAIL_TESTS = -EXTRA_DIST = $(TESTS) $(XFAIL_TESTS) - +EXTRA_DIST = $(TESTS) $(XFAIL_TESTS) vtpm_utils.py TESTS_ENVIRONMENT=@TENV@ %.test: %.py diff --git a/tools/xm-test/tests/vtpm/vtpm_utils.py b/tools/xm-test/tests/vtpm/vtpm_utils.py new file mode 100644 index 0000000000..34e4afd583 --- /dev/null +++ b/tools/xm-test/tests/vtpm/vtpm_utils.py @@ -0,0 +1,19 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2006 +# Author: Stefan Berger + +from XmTestLib import * + +if ENABLE_HVM_SUPPORT: + SKIP("vtpm tests not supported for HVM domains") + +if not os.path.isfile("/dev/tpm0"): + SKIP("This machine has no hardware TPM; cannot run this test") + +status, output = traceCommand("ps aux | grep vtpm_manager | grep -v grep") +if output == "": + FAIL("virtual TPM manager must be started to run this test") + +def vtpm_cleanup(domName): + traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName) -- 2.30.2